<?php
class hrd_detail_penghargaan_model extends MY_Model {
	var $nama_tabel = 'hrd_detail_penghargaan';
	
	function GetJSON($idKaryawan) {
		$ls_sql	= "	SELECT	a.id_detail_penghargaan_pk, b.nama_penghargaan, TO_CHAR(a.tgl_penghargaan,'DD/MM/YYYY') tgl_penghargaan, a.no_sk_penghargaan, a.pemberi_penghargaan, a.id_penghargaan_fk, a.ket_penghargaan
				FROM	".$this->nama_tabel." a
				LEFT JOIN HRD_PENGHARGAAN b ON a.id_penghargaan_fk = b.id_penghargaan_pk
				WHERE 	id_karyawan_fk = '".$idKaryawan."'
				ORDER BY tgl_penghargaan desc";

		return json_encode( $this->paging($ls_sql) );
	}

	function Add($arr_data){
		$this->db->insert($this->nama_tabel, $arr_data);
	}

	function Update($arr_data, $arr_rule){
		$this->db->update($this->nama_tabel, $arr_data, $arr_rule);
	}

	function DeleteSingle($arr_rule) {
		try {
			$this->db->delete($this->nama_tabel, array('id_detail_penghargaan_pk' => $arr_rule['id_detail_penghargaan_pk']));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}

}
?>